package likou;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/06 07:02
 */
public class _11 {
    public int maxArea1(int[] height) {
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < height.length; i++) {
            int j = 0;
            for (; j < i; j++) {
                max = Math.max(max, (i - j) * Math.min(height[i], height[j]));
            }
        }
        return max;
    }

    public int maxArea2(int[] height) {
        int max = Integer.MIN_VALUE;
        int left = 0, right = height.length-1;
        while (left<right){
            max = Math.max(max,(right-left)*Math.min(height[left],height[right]));
            if (height[left]<=height[right]){
                left++;
            }else {
                right++;
            }
        }
        return max;
    }
}
